#ifndef _LIBMS2SIM_H_
#define _LIBMS2SIM_H_

#include <clx/libECM.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef void	*msl_arrival_t;
typedef void	*msl_popularity_t;
typedef void	*msl_sesslen_t;
typedef void	*msl_iastat_t;
typedef void	*msl_istime_t;

typedef enum {
	MSL_SESSLEN_TYPE_NONE,
	MSL_SESSLEN_TYPE_FULL,
	MSL_SESSLEN_TYPE_BETA
} msl_sesslen_type_t;

typedef enum {
	MSL_ISTIME_TYPE_NONE,
	MSL_ISTIME_TYPE_NOSEEK,
	MSL_ISTIME_TYPE_LOGNORMAL
} msl_istime_type_t;

int msl_initialize(void);

msl_arrival_t msl_arrival_create(double mu, unsigned long seed);
unsigned int msl_arrival_get(msl_arrival_t msl_arrival);
void msl_arrival_free(msl_arrival_t msl_arrival);

msl_popularity_t msl_popularity_create(unsigned int size, double skew, unsigned long seed);
unsigned int msl_popularity_get(msl_popularity_t msl_popularity);
void msl_popularity_free(msl_popularity_t msl_popularity);

msl_sesslen_t msl_sesslen_create(msl_sesslen_type_t type, unsigned long seed);
int msl_sesslen_set_param(msl_sesslen_t msl_sesslen, ecm_double alpha, ecm_double beta);
unsigned int msl_sesslen_get(msl_sesslen_t msl_sesslen, unsigned long media_length);
void msl_sesslen_free(msl_sesslen_t msl_sesslen);

const char *msl_sesslen_get_typestr(msl_sesslen_type_t type);
msl_sesslen_type_t msl_sesslen_parse_typestr(const char *typestr);

msl_iastat_t msl_iastat_create(void);
void msl_iastat_add(msl_iastat_t msl_iastat, unsigned long long arrival_time);
unsigned int msl_iastat_get(msl_iastat_t msl_iastat);
void msl_iastat_free(msl_iastat_t msl_iastat);

msl_istime_t msl_istime_create(msl_istime_type_t type, unsigned long seed);
int msl_istime_set_param(msl_istime_t msl_istime, double mu, double sigma);
unsigned int msl_istime_get_seek(msl_istime_t msl_istime, unsigned int pos, unsigned int length,
				 unsigned int *pinterseek_time, int *pdistance);
void msl_istime_free(msl_istime_t msl_istime);

const char *msl_istime_get_typestr(msl_istime_type_t type);
msl_istime_type_t msl_istime_parse_typestr(const char *typestr);

/* Util */
extern const char *msl_get_duration_str(ecm_uint32 duration);
extern const char *msl_get_bandwidth_str(ecm_double bandwidth);
extern const char *msl_get_capacity_str(ecm_double capacity);

extern ecm_uint32 msl_parse_duration(char *str);
extern ECMBOOL msl_parse_arrival_rate(char *str, ecm_double *parrival_rate);
extern ECMBOOL msl_parse_bandwidth(char *str, ecm_uint64 *pBW);

#ifdef __cplusplus
}
#endif

#endif
